import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class platform here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class platform  extends object
{
    Zony z;
    int right,left,top,bottom,velX,velY;
    boolean stand,t;

    public platform(int l,int r,int x,int y,boolean type){
        right=r;
        left=l;
        velX=x;
        velY=y;
        t=type;
    }
    
    protected void addedToWorld(World world)
    {
        if(t)
            setImage(((it)getWorld()).getDropper());
        else
            setImage(((it)getWorld()).getPLatform());
        z = (Zony) getWorld().getObjects(Zony.class).get(0);
        top = getY()-left;
        bottom = getY()+right;
        right = getX()+right;
        left = getX()-left;   
    }  
    
    public void act() 
    {
        stand = z.getY()<getY()-16;
        setLocation(getX()+velX,getY()+velY);
        if(Math.abs(z.getX()-getX())<21 && Math.abs(z.getY()-getY()+19)<2)
            z.setLocation(z.getX()+velX,z.getY()+velY);
        if(getX()<left || getX()>right || getY()<top || getY()>bottom){
            velX=-velX;
            velY=-velY;
        }
    }   
    
    public boolean stand(){
        return stand;
    }
    
    public int vel(){
        return velX;
    }
    
    
    
    
}
